package com.crl.rcdp.sys.service;

import com.cars.util.global.GlobalOperaCode;
import com.cars.util.list.ListUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.crl.rcdp.sys.dao.SysApitypeDao;
import com.crl.rcdp.sys.dto.SysApitypeDTO;
import com.crl.rcdp.sys.model.SysApitype;
import com.crl.rcdp.sys.vo.SysApitypeSearchVO;
import java.util.List;

/**
 * @description: 系统管理-接口类型Service
 * @author: 孔垂云
 * @version: 1.0
 * @date: 2020-07-30 22:43:56
 */
@Service
public class SysApitypeService {
    @Autowired
    private SysApitypeDao sysApitypeDao;
    /**
     * 增加
     *
     * @param sysApitypeDTO
     * @return
     */
    public int add(SysApitypeDTO sysApitypeDTO) {
        SysApitype sysApitype = new SysApitype();
        BeanUtils.copyProperties(sysApitypeDTO, sysApitype);
        return sysApitypeDao.add(sysApitype);
    }
    /**
     * 修改
     *
     * @param sysApitypeDTO
     * @return
     */
    public int update(SysApitypeDTO sysApitypeDTO) {
        SysApitype sysApitype = new SysApitype();
        BeanUtils.copyProperties(sysApitypeDTO, sysApitype);
        return sysApitypeDao.update(sysApitype);
    }
    /**
     * 删除
     *
     * @param id
     * @return
     */
    public int delete(Long id) {
        SysApitype sysApitype = sysApitypeDao.get(id);
        if (sysApitype  == null) {
           return GlobalOperaCode.OPERA_NOT_EXIST;
         } else {
           return sysApitypeDao.delete(id);
         }
    }

    /**
     * 列表
     *
     * @param sysApitypeSearchVO
     * @return
     */
    public List<SysApitypeDTO> list(SysApitypeSearchVO sysApitypeSearchVO) {
        List<SysApitype> list = sysApitypeDao.list(sysApitypeSearchVO);
        List<SysApitypeDTO> listResult = ListUtils.copyList(list, SysApitypeDTO.class);
        return listResult;
    }
    /**
     * 记录条数
     *
     * @param sysApitypeSearchVO
     * @return
     */
    public int count(SysApitypeSearchVO sysApitypeSearchVO) {
        return sysApitypeDao.count(sysApitypeSearchVO);
    }
    /**
     * 获取单个
     *
     * @param id
     * @return
     */
    public SysApitypeDTO get(Long id) {
        SysApitype sysApitype = sysApitypeDao.get(id);
        SysApitypeDTO sysApitypeDTO = new SysApitypeDTO();
        BeanUtils.copyProperties(sysApitype, sysApitypeDTO);
        return sysApitypeDTO;
    }
}
